﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System_ComponentModel="clr-namespace:System.ComponentModel;assembly=System"
    xmlns:MiniTwitter="clr-namespace:MiniTwitter" xmlns:MiniTwitter_Controls="clr-namespace:MiniTwitter.Controls" xmlns:MiniTwitter_Properties="clr-namespace:MiniTwitter.Properties" xmlns:Input="clr-namespace:MiniTwitter.Models.Input">

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    <MiniTwitter_Controls:TextCountConverter x:Key="TextCountConverter"/>
    
    <MiniTwitter:FooterConverter x:Key="FooterConverter" />

    <MiniTwitter_Controls:TimelineStyleSelector x:Key="TimelineStyleSelector"/>

    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
        <Setter Property="Margin" Value="0,-2,0,-1" />
    </Style>

    <Style x:Key="FavoriteMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Setter Property="Header" Value="お気に入りに追加(_F)"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=Favorited}" Value="True">
                <Setter Property="Header" Value="お気に入りから削除(_U)"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="StandardMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=TimelineStyle}" Value="Standard">
                <Setter Property="IsChecked" Value="True"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="BalloonMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=TimelineStyle}" Value="Balloon">
                <Setter Property="IsChecked" Value="True"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ListMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=TimelineStyle}" Value="List">
                <Setter Property="IsChecked" Value="True"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="CreatedAtCategoryMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=SortCategory}" Value="CreatedAt">
                <Setter Property="IsChecked" Value="True"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ScreenNameCategoryMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=SortCategory}" Value="ScreenName">
                <Setter Property="IsChecked" Value="True"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="AscendingMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=SortDirection}" Value="Ascending">
                <Setter Property="IsChecked" Value="True"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="DescendingMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=SortDirection}" Value="Descending">
                <Setter Property="IsChecked" Value="True"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    
    <Style x:Key="UserTimelineMenuItemStyle" TargetType="{x:Type MenuItem}">
        <Setter Property="IsEnabled" Value="False"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=Type}" Value="User">
                <Setter Property="IsEnabled" Value="True"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=Type}" Value="Search">
                <Setter Property="IsEnabled" Value="True"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=Type}" Value="List">
                <Setter Property="IsEnabled" Value="True"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    
    <Style x:Key="TimelineTextStyle" TargetType="{x:Type MiniTwitter_Controls:TextViewer}">
        <Setter Property="Foreground" Value="Black" />
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsMention}" Value="True">
                <Setter Property="Foreground" Value="Red" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsAuthor}" Value="True">
                <Setter Property="Foreground" Value="Green" />
            </DataTrigger>
            <!--<DataTrigger Binding="{Binding Path=IsReTweeted}" Value="True">
                <Setter Property="Foreground" Value="Blue" />
            </DataTrigger>-->
        </Style.Triggers>
    </Style>

    <ContextMenu x:Key="TextBoxContextMenu">
        <MenuItem Header="元に戻す(_U)" Command="ApplicationCommands.Undo"/>
        <Separator/>
        <MenuItem Header="切り取り(_T)" Command="ApplicationCommands.Cut"/>
        <MenuItem Header="コピー(_C)" Command="ApplicationCommands.Copy"/>
        <MenuItem Header="貼り付け(_P)" Command="ApplicationCommands.Paste"/>
        <MenuItem Header="削除(_D)" Command="EditingCommands.Delete"/>
        <Separator/>
        <MenuItem Header="すべて選択(_A)" Command="ApplicationCommands.SelectAll"/>
        <Separator/>
        <MenuItem Header="挿入(_I)">
            <MenuItem Header="Twitpic へアップロード(_P)" Command="Input:Commands.Twitpic" />
            <Separator />
            <MenuItem Header="再生中の曲情報(_I)" Command="Input:Commands.PlayTitle" />
            <MenuItem Header="現在地の情報(_G)" Command="Input:Commands.GpsLocation" />
        </MenuItem>
        <Separator/>
        <MenuItem Header="フッター(_F)" ItemsSource="{Binding Path=TweetFooterHistory, Source={x:Static MiniTwitter_Properties:Settings.Default}}">
            <MenuItem.ItemContainerStyle>
                <Style TargetType="{x:Type MenuItem}">
                    <Setter Property="IsChecked" Value="{Binding Converter={StaticResource FooterConverter}, Mode=OneWay}" />
                    <Setter Property="Command" Value="Input:Commands.Footer" />
                    <Setter Property="CommandParameter" Value="{Binding}" />
                </Style>
            </MenuItem.ItemContainerStyle>
        </MenuItem>
    </ContextMenu>

    <ContextMenu x:Key="StatusContextMenu">
        <MenuItem Header="返信(_R)" Command="Input:Commands.Reply" CommandParameter="{Binding}" />
        <MenuItem Header="メッセージを送信(_D)" Command="Input:Commands.ReplyMessage" CommandParameter="{Binding}"/>
        <Separator />
        <MenuItem Header="ReTweet(_T)" Command="Input:Commands.ReTweetApi" CommandParameter="{Binding}" />
        <MenuItem Header="コメント付き ReTweet(_Q)" Command="Input:Commands.ReTweet" CommandParameter="{Binding}" />
        <Separator/>
        <MenuItem Command="Input:Commands.Favorite" CommandParameter="{Binding}" Style="{StaticResource FavoriteMenuItemStyle}"/>
        <Separator/>
        <MenuItem Header="ステータスを削除(_X)" IsEnabled="{Binding Path=IsAuthor}" Command="Input:Commands.Delete" CommandParameter="{Binding}"/>
        <Separator/>
        <MenuItem Header="すべて既読にする(_R)" Command="Input:Commands.ReadAll" />
        <Separator/>
        <MenuItem Header="移動(_M)" >
            <MenuItem Header="ユーザーページ(_H)" Command="Input:Commands.MoveToUserPage" CommandParameter="{Binding}"/>
            <Separator />
            <MenuItem Header="ステータスページ(_S)" Command="Input:Commands.MoveToStatusPage" CommandParameter="{Binding}"/>
            <MenuItem Header="宛先のステータスページ(_T)" Command="Input:Commands.MoveToReplyPage" CommandParameter="{Binding}">
                <MenuItem.Style>
                    <Style TargetType="{x:Type MenuItem}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=IsReply}" Value="False">
                                <Setter Property="IsEnabled" Value="False" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </MenuItem.Style>
            </MenuItem>
        </MenuItem>
        <MenuItem Header="フレンド(_A)">
            <MenuItem Header="フォローする(_F)" Command="Input:Commands.Follow" CommandParameter="{Binding}" />
            <MenuItem Header="フォローを解除する(_U)" Command="Input:Commands.Unfollow" CommandParameter="{Binding}" />
            <Separator />
            <MenuItem Header="ブロックする(_B)" Command="Input:Commands.Block" CommandParameter="{Binding}" />
        </MenuItem>
        <Separator/>
        <MenuItem Header="コピー(_C)">
            <MenuItem Header="ユーザー名(_I)" Command="Input:Commands.Copy" CommandParameter="{Binding Path=Sender.ScreenName}"/>
            <Separator/>
            <MenuItem Header="ステータス(_S)" Command="Input:Commands.Copy" CommandParameter="{Binding Path=Text}" />
            <MenuItem Header="ステータスURL(_U)" Command="Input:Commands.CopyUrl" CommandParameter="{Binding}"/>
        </MenuItem>
        <Separator/>
        <MenuItem Header="表示(_V)">
            <MenuItem Header="標準(_S)" Command="Input:Commands.TimelineStyle" CommandParameter="{x:Static MiniTwitter:TimelineStyle.Standard}" Style="{StaticResource StandardMenuItemStyle}"/>
            <MenuItem Header="吹き出し(_B)" Command="Input:Commands.TimelineStyle" CommandParameter="{x:Static MiniTwitter:TimelineStyle.Balloon}" Style="{StaticResource BalloonMenuItemStyle}"/>
            <MenuItem Header="一覧(_L)" Command="Input:Commands.TimelineStyle" CommandParameter="{x:Static MiniTwitter:TimelineStyle.List}" Style="{StaticResource ListMenuItemStyle}"/>
            <Separator/>
            <MenuItem Header="アイコンを表示(_I)" IsCheckable="True" IsChecked="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=IsIconVisible}"/>
        </MenuItem>
        <MenuItem Header="並べ替え(_O)">
            <MenuItem Header="ユーザー名" Command="Input:Commands.SortCategory" CommandParameter="{x:Static MiniTwitter:ListSortCategory.ScreenName}" Style="{StaticResource ScreenNameCategoryMenuItemStyle}"/>
            <MenuItem Header="更新日時" Command="Input:Commands.SortCategory" CommandParameter="{x:Static MiniTwitter:ListSortCategory.CreatedAt}" Style="{StaticResource CreatedAtCategoryMenuItemStyle}"/>
            <Separator/>
            <MenuItem Header="昇順(_A)" Command="Input:Commands.SortDirection" CommandParameter="{x:Static System_ComponentModel:ListSortDirection.Ascending}" Style="{StaticResource AscendingMenuItemStyle}"/>
            <MenuItem Header="降順(_D)" Command="Input:Commands.SortDirection" CommandParameter="{x:Static System_ComponentModel:ListSortDirection.Descending}" Style="{StaticResource DescendingMenuItemStyle}"/>
        </MenuItem>
        <Separator />
        <MenuItem Header="振り分け(_T)" DisplayMemberPath="Name" ItemsSource="{Binding Path=Timelines, RelativeSource={RelativeSource AncestorType={x:Type Window}}}">
            <MenuItem.ItemContainerStyle>
                <Style TargetType="{x:Type MenuItem}">
                    <Setter Property="Visibility" Value="Collapsed" />
                    <Setter Property="Command" Value="Input:Commands.Apportion" />
                    <Setter Property="CommandParameter" Value="{Binding}" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=Type}" Value="User">
                            <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </MenuItem.ItemContainerStyle>
        </MenuItem>
    </ContextMenu>

    <ContextMenu x:Key="MessageContextMenu">
        <MenuItem Header="返信(_R)" Command="Input:Commands.ReplyMessage" CommandParameter="{Binding}"/>
        <Separator/>
        <MenuItem Header="ユーザーページ(_H)" Command="Input:Commands.MoveToUserPage" CommandParameter="{Binding}"/>
        <Separator/>
        <MenuItem Header="メッセージを削除(_X)" Command="Input:Commands.Delete" CommandParameter="{Binding}"/>
        <Separator/>
        <MenuItem Header="コピー(_C)">
            <MenuItem Header="ユーザー名(_I)" Command="Input:Commands.Copy" CommandParameter="{Binding Path=Sender.ScreenName}"/>
            <Separator/>
            <MenuItem Header="メッセージ(_S)" Command="Input:Commands.Copy" CommandParameter="{Binding Path=Text}" />
        </MenuItem>
        <Separator/>
        <MenuItem Header="表示(_V)">
            <MenuItem Header="標準(_S)" Command="Input:Commands.TimelineStyle" CommandParameter="{x:Static MiniTwitter:TimelineStyle.Standard}" Style="{StaticResource StandardMenuItemStyle}"/>
            <MenuItem Header="吹き出し(_B)" Command="Input:Commands.TimelineStyle" CommandParameter="{x:Static MiniTwitter:TimelineStyle.Balloon}" Style="{StaticResource BalloonMenuItemStyle}"/>
            <MenuItem Header="一覧(_L)" Command="Input:Commands.TimelineStyle" CommandParameter="{x:Static MiniTwitter:TimelineStyle.List}" Style="{StaticResource ListMenuItemStyle}"/>
            <Separator/>
            <MenuItem Header="アイコンを表示(_I)" IsCheckable="True" IsChecked="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=IsIconVisible}"/>
        </MenuItem>
        <MenuItem Header="並べ替え(_O)">
            <MenuItem Header="ユーザー名" Command="Input:Commands.SortCategory" CommandParameter="{x:Static MiniTwitter:ListSortCategory.ScreenName}" Style="{StaticResource ScreenNameCategoryMenuItemStyle}"/>
            <MenuItem Header="更新日時" Command="Input:Commands.SortCategory" CommandParameter="{x:Static MiniTwitter:ListSortCategory.CreatedAt}" Style="{StaticResource CreatedAtCategoryMenuItemStyle}"/>
            <Separator/>
            <MenuItem Header="昇順(_A)" Command="Input:Commands.SortDirection" CommandParameter="{x:Static System_ComponentModel:ListSortDirection.Ascending}" Style="{StaticResource AscendingMenuItemStyle}"/>
            <MenuItem Header="降順(_D)" Command="Input:Commands.SortDirection" CommandParameter="{x:Static System_ComponentModel:ListSortDirection.Descending}" Style="{StaticResource DescendingMenuItemStyle}"/>
        </MenuItem>
    </ContextMenu>
    
    <ContextMenu x:Key="TimelineContextMenu">
        <MenuItem Header="新しいタイムライン(_A)..." Command="Input:Commands.AddTimeline" />
        <MenuItem Header="設定を変更(_E)..." Command="Input:Commands.EditTimeline" Style="{StaticResource UserTimelineMenuItemStyle}"/>
        <Separator/>
        <MenuItem Header="削除(_D)" Command="Input:Commands.DeleteTimeline" Style="{StaticResource UserTimelineMenuItemStyle}"/>
        <Separator/>
        <MenuItem Header="すべての項目を削除(_C)" Command="Input:Commands.ClearTimeline"/>
    </ContextMenu>

</ResourceDictionary>